# -*- coding: utf-8 -*-
"""
@File: urls.py
@author: chenxialin
@time: 4月 08, 2025 10:18
"""
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import AnnouncementViewSet, BookViewSet, BorrowRecordViewSet, BookBorrowReturnViewSet

# 创建路由器并注册视图集
router = DefaultRouter()
router.register(r'announcements', AnnouncementViewSet, basename='announcement')
router.register(r'books', BookViewSet, basename='book')
router.register(r'borrow-records', BorrowRecordViewSet, basename='borrow-record')
urlpatterns = [
    path('', include(router.urls)),  # 注册 API 路由
# 借书接口
    path('books/<int:pk>/borrow/', BookBorrowReturnViewSet.as_view({'post': 'borrow_book'}), name='borrow-book'),
    # 还书接口
    path('books/<int:pk>/return/', BookBorrowReturnViewSet.as_view({'post': 'return_book'}), name='return-book'),
]